<template>
  <el-dialog title="材料补充" :close-on-click-modal="false" :visible.sync="visible"
    class="JNPF-dialog JNPF-dialog_center" lock-scroll width="600px">

    <el-form ref="elForm" size="medium" label-width="100px" label-position="top" v-if="companyInfo">

      <el-form-item label="股东之间关系说明（公司章程）">
<!--        <UploadFiles v-model="fileList1" type="document" />-->
        <ali-upload v-model="fileList1" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="注册地址（地址合同）">
<!--        <UploadFiles v-model="fileList2" type="document" />-->
        <ali-upload v-model="fileList2" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="实际经营地址（租赁合同、近一年房租记录）">
<!--        <UploadFiles v-model="fileList3" type="document" />-->
        <ali-upload v-model="fileList3" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="主要生产流程（工艺流程图）">
<!--        <UploadFiles v-model="fileList4" type="document" />-->
        <ali-upload v-model="fileList4" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="参保员工人数（社保系统参保人员汇总表）">
<!--        <UploadFiles v-model="fileList5" type="document" />-->
        <ali-upload v-model="fileList5" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="非参保员工人数（人员信息表、近三个月发薪记录）">
<!--        <UploadFiles v-model="fileList6" type="document"/>-->
        <ali-upload v-model="fileList6" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="兼职员工人数（人员信息表、最近一次发薪记录）">
<!--        <UploadFiles v-model="fileList7"  type="document"/>-->
        <ali-upload v-model="fileList7" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="企业财务信息（资产负债表、利润表、增值税纳税申报表主表）">
<!--        <UploadFiles v-model="fileList8"   type="document" />-->
        <ali-upload v-model="fileList8" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="实际控制人近一年流水（银行流水、支付宝微信流水）">
<!--        <UploadFiles v-model="fileList9"  type="document"/>-->
        <ali-upload v-model="fileList9" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="企业人行征信（人行征信报告）">
<!--        <UploadFiles v-model="fileList10"  type="document" />-->
        <ali-upload v-model="fileList10" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="重大关系人人行征信（人行征信报告）">
<!--        <UploadFiles v-model="fileList11"  type="document" />-->
        <ali-upload v-model="fileList11" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="企业涉诉情况（法院法律文件、裁判文书网和执行信息公开网截图）">
<!--        <UploadFiles v-model="fileList12"   type="document"/>-->
        <ali-upload v-model="fileList12" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="实际控制人工作经验">
<!--        <UploadFiles v-model="fileList13"   type="document"/>-->
        <ali-upload v-model="fileList13" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="近一年经营流水">
<!--        <UploadFiles v-model="fileList14"   type="document"/>-->
        <ali-upload v-model="fileList14" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="企业历史经营异常及违法失信信息">
<!--        <UploadFiles v-model="fileList15"   type="document"/>-->
        <ali-upload v-model="fileList15" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
      <el-form-item label="企业客户数字服务合同和发票">
<!--        <UploadFiles v-model="fileList16"   type="document"/>-->
        <ali-upload v-model="fileList16" :filePath="companyInfo.businessId"></ali-upload>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible=false">取 消</el-button>
      <el-button type="primary" @click="dataFormSubmit">保 存</el-button>
    </span>
  </el-dialog>
</template>

<script>
import AliUpload from "@/components/Upload/AliUpload";
import request from "@/utils/request";
import UploadFiles from "@/components/Upload/UploadFiles";
export default {
  components:{
    AliUpload,UploadFiles
  },
  data() {
    return {
      visible: false,
      btnLoading: false,
      fileList1:[],
      fileList2:[],
      fileList3:[],
      fileList4:[],
      fileList5:[],
      fileList6:[],
      fileList7:[],
      fileList8:[],
      fileList9:[],
      fileList10:[],
      fileList11:[],
      fileList12:[],
      fileList13:[],
      fileList14:[],
      fileList15:[],
      fileList16:[],
      companyInfo:null
    }
  },
  methods: {
    init(row) {
      this.visible = true
      this.companyInfo=row
      request({
        url: `/api/Jiushi/Customerattachment`,
        method: 'get',
        data:{
          customerId:this.companyInfo.id,
          businessId:this.companyInfo.businessId,
          currentPage: 1,
          pageSize: 200,
        },
      }).then((res) => {
        let tempData=res.data.list
        this.fileList1=tempData.filter((item)=>item.attachmentType=='gongsizhangcheng').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList2=tempData.filter((item)=>item.attachmentType=='zhucedizhi').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList3=tempData.filter((item)=>item.attachmentType=='jingyingdizhi').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList4=tempData.filter((item)=>item.attachmentType=='shengchanliucheng').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList5=tempData.filter((item)=>item.attachmentType=='canbaorenyuan').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList6=tempData.filter((item)=>item.attachmentType=='feicanbaorenyuan').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList7=tempData.filter((item)=>item.attachmentType=='jianzhirenyuan').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList8=tempData.filter((item)=>item.attachmentType=='caiwuxinxi').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList9=tempData.filter((item)=>item.attachmentType=='shijikongzhiren').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList10=tempData.filter((item)=>item.attachmentType=='qiyerenhangzhengxin').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList11=tempData.filter((item)=>item.attachmentType=='guanxirenzhengxin').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList12=tempData.filter((item)=>item.attachmentType=='shequqingkuang').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList13=tempData.filter((item)=>item.attachmentType=='sjkzrgzjy').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList14=tempData.filter((item)=>item.attachmentType=='jynjyls').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList15=tempData.filter((item)=>item.attachmentType=='qylsjyycjwfsxxx').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
        this.fileList16=tempData.filter((item)=>item.attachmentType=='qykhszfwhthfp').map(attach=>{
          let tempItem={
            id:attach.id,
            name:attach.attachmentName,
            url:attach.attachmentPath
          }
          return tempItem
        })
      })
    },
    dataFormSubmit() {
      let tempList=[]
      if(this.fileList1.length>0){
        for (let i = 0; i <this.fileList1.length; i++) {
          if(!this.fileList1[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList1[i].response?this.fileList1[i].fileName:this.fileList1[i].name,
              attachmentType:'gongsizhangcheng',
              attachmentPath:this.fileList1[i].response?this.fileList1[i].response.data.url:this.fileList1[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList2.length>0){
        for (let i = 0; i <this.fileList2.length; i++) {
          if(!this.fileList2[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList2[i].response?this.fileList2[i].fileName:this.fileList2[i].name,
              attachmentType:'zhucedizhi',
              attachmentPath:this.fileList2[i].response?this.fileList2[i].response.data.url:this.fileList2[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList3.length>0){
        for (let i = 0; i <this.fileList3.length; i++) {
          if(!this.fileList3[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList3[i].response?this.fileList3[i].fileName:this.fileList3[i].name,
              attachmentType:'jingyingdizhi',
              attachmentPath:this.fileList3[i].response?this.fileList3[i].response.data.url:this.fileList3[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList4.length>0){
        for (let i = 0; i <this.fileList4.length; i++) {
          if(!this.fileList4[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList4[i].response?this.fileList4[i].fileName:this.fileList4[i].name,
              attachmentType:'shengchanliucheng',
              attachmentPath:this.fileList4[i].response?this.fileList4[i].response.data.url:this.fileList4[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList5.length>0){
        for (let i = 0; i <this.fileList5.length; i++) {
          if(!this.fileList5[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList5[i].response?this.fileList5[i].fileName:this.fileList5[i].name,
              attachmentType:'canbaorenyuan',
              attachmentPath:this.fileList5[i].response?this.fileList5[i].response.data.url:this.fileList5[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList6.length>0){
        for (let i = 0; i <this.fileList6.length; i++) {
          if(!this.fileList6[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList6[i].response?this.fileList6[i].fileName:this.fileList6[i].name,
              attachmentType:'feicanbaorenyuan',
              attachmentPath:this.fileList6[i].response?this.fileList6[i].response.data.url:this.fileList6[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList7.length>0){
        for (let i = 0; i <this.fileList7.length; i++) {
          if(!this.fileList7[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList7[i].response?this.fileList7[i].fileName:this.fileList7[i].name,
              attachmentType:'jianzhirenyuan',
              attachmentPath:this.fileList7[i].response?this.fileList7[i].response.data.url:this.fileList7[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList8.length>0){
        for (let i = 0; i <this.fileList8.length; i++) {
          if(!this.fileList8[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList8[i].response?this.fileList8[i].fileName:this.fileList8[i].name,
              attachmentType:'caiwuxinxi',
              attachmentPath:this.fileList8[i].response?this.fileList8[i].response.data.url:this.fileList8[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList9.length>0){
        for (let i = 0; i <this.fileList9.length; i++) {
          if(!this.fileList9[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList9[i].response?this.fileList9[i].fileName:this.fileList9[i].name,
              attachmentType:'shijikongzhiren',
              attachmentPath:this.fileList9[i].response?this.fileList9[i].response.data.url:this.fileList9[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList10.length>0){
        for (let i = 0; i <this.fileList10.length; i++) {
          if(!this.fileList10[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList10[i].response?this.fileList10[i].fileName:this.fileList10[i].name,
              attachmentType:'qiyerenhangzhengxin',
              attachmentPath:this.fileList10[i].response?this.fileList10[i].response.data.url:this.fileList10[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList11.length>0){
        for (let i = 0; i <this.fileList11.length; i++) {
          if(!this.fileList11[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList11[i].response?this.fileList11[i].fileName:this.fileList11[i].name,
              attachmentType:'guanxirenzhengxin',
              attachmentPath:this.fileList11[i].response?this.fileList11[i].response.data.url:this.fileList11[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList12.length>0){
        for (let i = 0; i <this.fileList12.length; i++) {
          if(!this.fileList12[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList12[i].response?this.fileList12[i].fileName:this.fileList12[i].name,
              attachmentType:'shequqingkuang',
              attachmentPath:this.fileList12[i].response?this.fileList12[i].response.data.url:this.fileList12[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList13.length>0){
        for (let i = 0; i <this.fileList13.length; i++) {
          if(!this.fileList13[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList13[i].response?this.fileList13[i].fileName:this.fileList13[i].name,
              attachmentType:'sjkzrgzjy',
              attachmentPath:this.fileList13[i].response?this.fileList13[i].response.data.url:this.fileList13[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList14.length>0){
        for (let i = 0; i <this.fileList14.length; i++) {
          if(!this.fileList14[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList14[i].response?this.fileList14[i].fileName:this.fileList14[i].name,
              attachmentType:'jynjyls',
              attachmentPath:this.fileList14[i].response?this.fileList14[i].response.data.url:this.fileList14[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList15.length>0){
        for (let i = 0; i <this.fileList15.length; i++) {
          if(!this.fileList15[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList15[i].response?this.fileList15[i].fileName:this.fileList15[i].name,
              attachmentType:'qylsjyycjwfsxxx',
              attachmentPath:this.fileList15[i].response?this.fileList15[i].response.data.url:this.fileList15[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      if(this.fileList16.length>0){
        for (let i = 0; i <this.fileList16.length; i++) {
          if(!this.fileList16[i].id){
            let tempItem={
              customerId:this.companyInfo.id,
              businessId:this.companyInfo.businessId,
              attachmentName:this.fileList16[i].response?this.fileList16[i].fileName:this.fileList16[i].name,
              attachmentType:'qykhszfwhthfp',
              attachmentPath:this.fileList16[i].response?this.fileList16[i].response.data.url:this.fileList16[i].url,
            }
            tempList.push(tempItem)
          }
        }
      }
      request({
        url: `/api/Jiushi/Customerattachment/CreateMultiple`,
        method: 'Post',
       	data: {json:JSON.stringify(tempList) }
      }).then((res) => {
        this.$message({
          message: '保存成功',
          type: 'success',
          duration: 1000,
          onClose: () => {
            this.visible = false;
            this.$emit('refresh', true);
          }
        })
      })
    },
  }
}
</script>
<style lang="scss" scoped>
>>> .el-dialog__body {
  padding: 20px !important;
}
</style>
